\(\int \frac {\frac {b B}{3}+B \sin (x)}{3+b \sin (x)} \, dx\) [694]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [F(-2)]
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 20, antiderivative size = 49 \[ \int \frac {\frac {b B}{3}+B \sin (x)}{3+b \sin (x)} \, dx=\frac {B x}{b}-\frac {2 \sqrt {9-b^2} B \arctan \left (\frac {b+3 \tan \left (\frac {x}{2}\right )}{\sqrt {9-b^2}}\right )}{3 b} \]

[Out]

B*x/b-2*B*arctan((b+a*tan(1/2*x))/(a^2-b^2)^(1/2))*(a^2-b^2)^(1/2)/a/b

Rubi [A] (verified)

Time = 0.06 (sec) , antiderivative size = 54, normalized size of antiderivative = 1.10, number of steps used = 4, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.200, Rules used = {2814, 2739, 632, 210} \[ \int \frac {\frac {b B}{3}+B \sin (x)}{3+b \sin (x)} \, dx=\frac {B x}{b}-\frac {2 B \sqrt {a^2-b^2} \arctan \left (\frac {a \tan \left (\frac {x}{2}\right )+b}{\sqrt {a^2-b^2}}\right )}{a b} \]

[In]

Int[((b*B)/a + B*Sin[x])/(a + b*Sin[x]),x]

[Out]

(B*x)/b - (2*Sqrt[a^2 - b^2]*B*ArcTan[(b + a*Tan[x/2])/Sqrt[a^2 - b^2]])/(a*b)

Rule 210

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(-(Rt[-a, 2]*Rt[-b, 2])^(-1))*ArcTan[Rt[-b, 2]*(x/Rt[-a, 2])
], x] /; FreeQ[{a, b}, x] && PosQ[a/b] && (LtQ[a, 0] || LtQ[b, 0])

Rule 632

Int[((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Dist[-2, Subst[Int[1/Simp[b^2 - 4*a*c - x^2, x], x]
, x, b + 2*c*x], x] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 2739

Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x]}, Dis
t[2*(e/d), Subst[Int[1/(a + 2*b*e*x + a*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] &&
 NeQ[a^2 - b^2, 0]

Rule 2814

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[b*(x/d)
, x] - Dist[(b*c - a*d)/d, Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d
, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {B x}{b}-\frac {\left (a B-\frac {b^2 B}{a}\right ) \int \frac {1}{a+b \sin (x)} \, dx}{b} \\ & = \frac {B x}{b}-\frac {\left (2 \left (a B-\frac {b^2 B}{a}\right )\right ) \text {Subst}\left (\int \frac {1}{a+2 b x+a x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{b} \\ & = \frac {B x}{b}+\frac {\left (4 \left (a B-\frac {b^2 B}{a}\right )\right ) \text {Subst}\left (\int \frac {1}{-4 \left (a^2-b^2\right )-x^2} \, dx,x,2 b+2 a \tan \left (\frac {x}{2}\right )\right )}{b} \\ & = \frac {B x}{b}-\frac {2 \sqrt {a^2-b^2} B \arctan \left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{a b} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.13 (sec) , antiderivative size = 48, normalized size of antiderivative = 0.98 \[ \int \frac {\frac {b B}{3}+B \sin (x)}{3+b \sin (x)} \, dx=\frac {B \left (3 x-2 \sqrt {9-b^2} \arctan \left (\frac {b+3 \tan \left (\frac {x}{2}\right )}{\sqrt {9-b^2}}\right )\right )}{3 b} \]

[In]

Integrate[((b*B)/3 + B*Sin[x])/(3 + b*Sin[x]),x]

[Out]

(B*(3*x - 2*Sqrt[9 - b^2]*ArcTan[(b + 3*Tan[x/2])/Sqrt[9 - b^2]]))/(3*b)

Maple [A] (verified)

Time = 0.72 (sec) , antiderivative size = 67, normalized size of antiderivative = 1.37

method result size
default \(\frac {2 B \left (\frac {\left (-a^{2}+b^{2}\right ) \arctan \left (\frac {2 a \tan \left (\frac {x}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{b \sqrt {a^{2}-b^{2}}}+\frac {a \arctan \left (\tan \left (\frac {x}{2}\right )\right )}{b}\right )}{a}\) \(67\)
risch \(\frac {B x}{b}+\frac {\sqrt {-a^{2}+b^{2}}\, B \ln \left ({\mathrm e}^{i x}+\frac {i a -\sqrt {-a^{2}+b^{2}}}{b}\right )}{b a}-\frac {\sqrt {-a^{2}+b^{2}}\, B \ln \left ({\mathrm e}^{i x}+\frac {i a +\sqrt {-a^{2}+b^{2}}}{b}\right )}{b a}\) \(103\)

[In]

int((b*B/a+B*sin(x))/(a+b*sin(x)),x,method=_RETURNVERBOSE)

[Out]

2*B/a*((-a^2+b^2)/b/(a^2-b^2)^(1/2)*arctan(1/2*(2*a*tan(1/2*x)+2*b)/(a^2-b^2)^(1/2))+a/b*arctan(tan(1/2*x)))

Fricas [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 163, normalized size of antiderivative = 3.33 \[ \int \frac {\frac {b B}{3}+B \sin (x)}{3+b \sin (x)} \, dx=\left [\frac {2 \, B a x + \sqrt {-a^{2} + b^{2}} B \log \left (\frac {{\left (2 \, a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2} + 2 \, {\left (a \cos \left (x\right ) \sin \left (x\right ) + b \cos \left (x\right )\right )} \sqrt {-a^{2} + b^{2}}}{b^{2} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2}}\right )}{2 \, a b}, \frac {B a x + \sqrt {a^{2} - b^{2}} B \arctan \left (-\frac {a \sin \left (x\right ) + b}{\sqrt {a^{2} - b^{2}} \cos \left (x\right )}\right )}{a b}\right ] \]

[In]

integrate((b*B/a+B*sin(x))/(a+b*sin(x)),x, algorithm="fricas")

[Out]

[1/2*(2*B*a*x + sqrt(-a^2 + b^2)*B*log(((2*a^2 - b^2)*cos(x)^2 - 2*a*b*sin(x) - a^2 - b^2 + 2*(a*cos(x)*sin(x)
 + b*cos(x))*sqrt(-a^2 + b^2))/(b^2*cos(x)^2 - 2*a*b*sin(x) - a^2 - b^2)))/(a*b), (B*a*x + sqrt(a^2 - b^2)*B*a
rctan(-(a*sin(x) + b)/(sqrt(a^2 - b^2)*cos(x))))/(a*b)]

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 170 vs. \(2 (41) = 82\).

Time = 12.79 (sec) , antiderivative size = 170, normalized size of antiderivative = 3.47 \[ \int \frac {\frac {b B}{3}+B \sin (x)}{3+b \sin (x)} \, dx=\begin {cases} \text {NaN} & \text {for}\: a = 0 \wedge b = 0 \\- \frac {B \cos {\left (x \right )}}{a} & \text {for}\: b = 0 \\\frac {B x}{b} & \text {for}\: a = - b \vee a = b \\- \frac {B a \log {\left (\tan {\left (\frac {x}{2} \right )} + \frac {b}{a} - \frac {\sqrt {- a^{2} + b^{2}}}{a} \right )}}{b \sqrt {- a^{2} + b^{2}}} + \frac {B a \log {\left (\tan {\left (\frac {x}{2} \right )} + \frac {b}{a} + \frac {\sqrt {- a^{2} + b^{2}}}{a} \right )}}{b \sqrt {- a^{2} + b^{2}}} + \frac {B x}{b} + \frac {B b \log {\left (\tan {\left (\frac {x}{2} \right )} + \frac {b}{a} - \frac {\sqrt {- a^{2} + b^{2}}}{a} \right )}}{a \sqrt {- a^{2} + b^{2}}} - \frac {B b \log {\left (\tan {\left (\frac {x}{2} \right )} + \frac {b}{a} + \frac {\sqrt {- a^{2} + b^{2}}}{a} \right )}}{a \sqrt {- a^{2} + b^{2}}} & \text {otherwise} \end {cases} \]

[In]

integrate((b*B/a+B*sin(x))/(a+b*sin(x)),x)

[Out]

Piecewise((nan, Eq(a, 0) & Eq(b, 0)), (-B*cos(x)/a, Eq(b, 0)), (B*x/b, Eq(a, b) | Eq(a, -b)), (-B*a*log(tan(x/
2) + b/a - sqrt(-a**2 + b**2)/a)/(b*sqrt(-a**2 + b**2)) + B*a*log(tan(x/2) + b/a + sqrt(-a**2 + b**2)/a)/(b*sq
rt(-a**2 + b**2)) + B*x/b + B*b*log(tan(x/2) + b/a - sqrt(-a**2 + b**2)/a)/(a*sqrt(-a**2 + b**2)) - B*b*log(ta
n(x/2) + b/a + sqrt(-a**2 + b**2)/a)/(a*sqrt(-a**2 + b**2)), True))

Maxima [F(-2)]

Exception generated. \[ \int \frac {\frac {b B}{3}+B \sin (x)}{3+b \sin (x)} \, dx=\text {Exception raised: ValueError} \]

[In]

integrate((b*B/a+B*sin(x))/(a+b*sin(x)),x, algorithm="maxima")

[Out]

Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(4*b^2-4*a^2>0)', see `assume?`
 for more de

Giac [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 73, normalized size of antiderivative = 1.49 \[ \int \frac {\frac {b B}{3}+B \sin (x)}{3+b \sin (x)} \, dx=\frac {B x}{b} - \frac {2 \, {\left (B a^{2} - B b^{2}\right )} {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (a\right ) + \arctan \left (\frac {a \tan \left (\frac {1}{2} \, x\right ) + b}{\sqrt {a^{2} - b^{2}}}\right )\right )}}{\sqrt {a^{2} - b^{2}} a b} \]

[In]

integrate((b*B/a+B*sin(x))/(a+b*sin(x)),x, algorithm="giac")

[Out]

B*x/b - 2*(B*a^2 - B*b^2)*(pi*floor(1/2*x/pi + 1/2)*sgn(a) + arctan((a*tan(1/2*x) + b)/sqrt(a^2 - b^2)))/(sqrt
(a^2 - b^2)*a*b)

Mupad [B] (verification not implemented)

Time = 8.27 (sec) , antiderivative size = 94, normalized size of antiderivative = 1.92 \[ \int \frac {\frac {b B}{3}+B \sin (x)}{3+b \sin (x)} \, dx=\frac {2\,B\,\mathrm {atan}\left (\frac {\sin \left (\frac {x}{2}\right )}{\cos \left (\frac {x}{2}\right )}\right )}{b}+\frac {2\,B\,\mathrm {atanh}\left (\frac {-\sin \left (\frac {x}{2}\right )\,a^2+\cos \left (\frac {x}{2}\right )\,a\,b+2\,\sin \left (\frac {x}{2}\right )\,b^2}{\sqrt {b^2-a^2}\,\left (2\,b\,\sin \left (\frac {x}{2}\right )+a\,\cos \left (\frac {x}{2}\right )\right )}\right )\,\sqrt {b^2-a^2}}{a\,b} \]

[In]

int((B*sin(x) + (B*b)/a)/(a + b*sin(x)),x)

[Out]

(2*B*atan(sin(x/2)/cos(x/2)))/b + (2*B*atanh((2*b^2*sin(x/2) - a^2*sin(x/2) + a*b*cos(x/2))/((b^2 - a^2)^(1/2)
*(2*b*sin(x/2) + a*cos(x/2))))*(b^2 - a^2)^(1/2))/(a*b)